<!--
 * @Author: your name
 * @Date: 2023-02-27 10:57:03
 * @LastEditTime: 2023-11-21 16:41:24
 * @LastEditors: DESKTOP-4QFD9PO
 * @Description: In User Settings Edit
 * @FilePath: \ClothMes\src\views\FirstInspectionRecordList\FirstInspectionRecordListDemo.vue
-->
<template>
  <pageTabelLayout>
    <template #pageHeader>
      <div class="search-form divClass" v-if="headerShow">
        <div>
          <a-form size="small" :model="pageData" layout="inline">
            <a-form-item label="织布单号" label-col-flex="80px">
              <a-input allow-clear :style="{ width: '180px' }" class="bacClass" placeholder=""
                       v-model="pageData.planOrderCode" @press-enter="huiche"/>
            </a-form-item>
            <a-form-item label="调机单号" label-col-flex="80px">
              <a-input allow-clear :style="{ width: '180px' }" class="bacClass" placeholder=""
                       v-model="pageData.adjustmentCode" @press-enter="huiche"/>
            </a-form-item>
            <a-form-item label="生产单号" label-col-flex="80px">
              <a-input allow-clear :style="{ width: '180px' }" class="bacClass" placeholder=""
                       v-model="pageData.weaveCode" @press-enter="huiche"/>
            </a-form-item>
            <a-form-item label="调机开始时间" label-col-flex="100px">
              <a-date-picker popup-container="html" class="bacClass" v-model="pageData.dateStart"/>
              至
              <a-date-picker popup-container="html" class="bacClass"
                             v-model="pageData.dateEnd"/>
            </a-form-item>
            <a-form-item label="查布头结果" label-col-flex="80px">
              <a-select popup-container="html" style="width: 165px" allow-clear class="bacClass" placeholder=""
                        v-model="pageData.inspectionState">
                <a-option :value="-1">全部</a-option>
                <a-option :value="0">未检验</a-option>
                <a-option :value="1">不OK</a-option>
                <a-option :value="2">OK</a-option>
              </a-select>
            </a-form-item>
            <a-form-item label="完结状态" label-col-flex="80px">
              <a-select popup-container="html" style="width: 180px" allow-clear class="bacClass" placeholder=""
                        v-model="pageData.adjustmentState">
                <a-option :value="-1">全部</a-option>
                <a-option :value="2">未完结</a-option>
                <a-option :value="3">已完结</a-option>
              </a-select>
            </a-form-item>
          </a-form>
        </div>
        <div class="my-tool-bar">
          <Toolbar style="float: right" :items="pageData.btnList" @select="selectHandler" @export="exports">
          </Toolbar>
        </div>
      </div>
      <div class="my-divisders">
        <a-divider orientation="center">
          <icon-double-up v-if="headerShow" @click="headerShow = false" :strokeWidth="2" :size="18"/>
          <icon-double-down v-else @click="headerShow = true" :strokeWidth="2" :size="18"/>
        </a-divider>
      </div>
    </template>
    <template #pageTabel>
      <a-spin :loading="pageData.pageLoading" tip="加载中" dot style="height: 100%; width: 100%; z-index: 999">
        <AgGridVuesCopys :rowHeight="33" :headerHeight="33" :suppressCopyRowsToClipboard="true"
                         :suppressDragLeaveHidesColumns="true" rowSelection="multiple"
                         @grid-ready="gridReady" @columnResized="onColumnResized" @columnVisible="onColumnVisible"
                         @columnMoved="onColumnMoved" style="height: 100%" :defaultColDef="defaultColDef"
                         class="ag-theme-alpine"
                         :rowData="table.dataList" :columnDefs="tc" :localeText="localeText1"></AgGridVuesCopys>
      </a-spin>
    </template>
    <paginationCopys :page-size-options="pagingList1" :page-size="pagination.pageSize" :current="pagination.page"
                     :total="total" show-total show-jumper show-page-size @change="PageSize" @page-size-change="change1"
                     style="justify-content: center"/>
    <a-modal v-model:visible="visible" @cancel="handleCancel" :width="1000" draggable>
      <template #title>
        详情
      </template>
      <template #footer>
        <a-button @click="handleCancel"> 关闭</a-button>
      </template>
      <a-form size="small" :model="dataForm" layout="inline">
        <a-form-item label="调机单号" disabled>
          <a-input allow-clear :style="{ width: '200px' }" class="bacClass" placeholder=""
                   v-model="dataForm.adjustmentCode"/>
        </a-form-item>
        <a-form-item label="织布单号" disabled>
          <a-input allow-clear :style="{ width: '200px' }" class="bacClass" placeholder=""
                   v-model="dataForm.planOrderCode"/>
        </a-form-item>
        <a-form-item label="生产单号" disabled>
          <a-input allow-clear :style="{ width: '200px' }" class="bacClass" placeholder=""
                   v-model="dataForm.weaveCode"/>
        </a-form-item>
        <a-form-item label="机台号" label-col-flex="65px" disabled>
          <a-input allow-clear :style="{ width: '200px' }" class="bacClass" placeholder=""
                   v-model="dataForm.machineCode"/>
        </a-form-item>
      </a-form>
      <a-table stripe :bordered="true" :columns="tableColumnsCf" size="mini" :loading="table.tableLoading"
               :data="dataForm.list">
        <template #verifySureOk="{ record }">
          <el-tag class="ml-2" v-if="record.verifySureOk == 1" type="success">OK</el-tag>
          <el-tag class="ml-2" v-if="record.verifySureOk == 0" type="warning">不OK</el-tag>
        </template>
      </a-table>
    </a-modal>
    <a-modal v-model:visible="visible1" @ok="handleOk" @cancel="visible1 = false" :width="1000" draggable>
      <template #title>
        登记
      </template>
      <template #footer>
        <a-button @click="okClick" type="primary"> OK</a-button>
        <a-button @click="handleCancel1"> 不OK</a-button>
      </template>
      <a-form size="small" :model="dataForm" ref="formRef">
        <a-row :gutter="16">
          <a-col :span="8">
            <a-form-item label="调机单号" label-col-flex="80px" disabled>
              <a-input allow-clear :style="{ width: '200px' }" class="bacClass" placeholder=""
                       v-model="dataForm.adjustmentCode"/>
            </a-form-item>
          </a-col>
          <a-col :span="8">
            <a-form-item label="生产单号" label-col-flex="80px" disabled>
              <a-input allow-clear :style="{ width: '200px' }" class="bacClass" placeholder=""
                       v-model="dataForm.weaveCode"/>
            </a-form-item>
          </a-col>
          <a-col :span="8">
            <a-form-item label="机台号" label-col-flex="80px" disabled>
              <a-input allow-clear :style="{ width: '210px' }" class="bacClass" placeholder=""
                       v-model="dataForm.machineCode"/>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row :gutter="16">
          <a-col :span="8">
            <a-form-item label="查布头人员" label-col-flex="80px" disabled>
              <a-input allow-clear :style="{ width: '200px' }" class="bacClass" placeholder=""
                       v-model="dataForm.firstverifyUser"/>
            </a-form-item>
          </a-col>
          <a-col :span="8">
            <a-form-item label="查布头日期" label-col-flex="80px" disabled>
              <a-date-picker popup-container="html" class="bacClass" :style="{ width: '200px' }"
                             v-model="dataForm.firstverifyDate"
                             placeholder=" " format="YYYY-MM-DD"/>
            </a-form-item>
          </a-col>
          <a-col :span="8">
            <a-form-item label="调机布重量" label-col-flex="80px" field="adjustmentClothWeight">
              <a-input-number class="bacClass" :style="{ width: '210px' }" v-model="dataForm.adjustmentClothWeight"
                              placeholder=""/>
            </a-form-item>
          </a-col>
        </a-row>
        <a-row :gutter="16">
          <a-col :span="8">
            <a-form-item label="疵点问题" label-col-flex="80px" field="defectNames">
              <a-select popup-container="html" :style="{ width: '200px' }" v-model="dataForm.defectNames" allow-clear
                        placeholder="" multiple
                        class="bacClass">
                <a-option v-for="(item, index) in pageData.defectNameList" :value="item['defectName']">{{
                    item['defectName']
                  }}
                </a-option>
              </a-select>
            </a-form-item>
          </a-col>
          <a-col :span="8">
            <a-form-item label="备注" label-col-flex="80px" field="remark">
              <a-textarea class="bacClass" v-model="dataForm.remark" :max-length="200" allow-clear show-word-limit
                          :style="{ width: '200px' }"/>
            </a-form-item>
          </a-col>
        </a-row>


      </a-form>

    </a-modal>
  </pageTabelLayout>
</template>

<script lang="ts">
import {pagingList} from '@/api/paging'
import {post} from '@/api/http'
import {useTable, useRowKey, useTableColumn, usePagination, useRowSelection} from '@/hooks/table'
import emitter from '@/hooks/useEventBus'
import {ref, reactive, onMounted, toRefs} from 'vue'
import Toolbar from '@/components/Toolbar.vue'
import {Form, Message, Modal} from '@arco-design/web-vue'
import {FormInstance} from '@arco-design/web-vue/es/form'
import {baseURL} from '../../../api/axios.config'
import axios from 'axios'
import filedownload from 'js-file-download'
import usePermission from '@/store/modules/permission'
import PageTabelLayout from '@/components/pageTabelLayout.vue'
import {AnyARecord} from 'dns'
import {EXELTABLE} from '@/utils/exportEXCEL';

import {localeText} from '@/api/aggridZw'
import {saveOrUpdateGridState as saveOrUpdateGridState01} from '@/hooks/useGridState'

interface BrandInfo {
  id: any
  firm: null
  adjustmentCode: any
  machineCode: any
  areaName: any
  weaveCode: any
  planOrderCode: any
  greyCode: any
  grayName: any
  startTime: any
  adjustmentWeight: any
  firstCount: any
  inspectionState: any
  list: any[]
  firstverifyUser: any
  firstverifyDate: any
  defectNames: any
  adjustmentClothWeight: any
  remark: any
}

export default {
  name: 'FirstInspectionRecordListDemo',
  setup() {
    const dataForm = reactive<BrandInfo>({
      id: null,
      firm: null,
      adjustmentCode: null,
      machineCode: null,
      areaName: null,
      weaveCode: null,
      planOrderCode: null,
      greyCode: null,
      grayName: null,
      startTime: null,
      adjustmentWeight: null,
      firstCount: null,
      inspectionState: null,
      list: [],
      firstverifyUser: null,
      firstverifyDate: Date.now(),
      defectNames: [],
      adjustmentClothWeight: null,
      remark: ''
    })
    const total = ref(0)
    const page = ref(1)
    const size = ref(10)

    function PageSize(val: any) {
      pagination.page = val
      doRefresh()
    }

    function change1(val: any) {
      pagination.pageSize = val
      doRefresh()
    }

    const headerShow = ref<boolean>(true)

    //查询方法
    function doRefresh() {
      pageData.pageLoading = true
      updateGridState01()
      post({
        url: 'planSingle/adjustment/getPageByFirst',
        data: {
          page: pagination.page,
          size: pagination.pageSize,
          empStartTimeStart: pageData.dateStart,
          empStartTimeEnd: pageData.dateEnd,
          adjustmentCode: pageData.adjustmentCode,
          planOrderCode: pageData.planOrderCode,
          weaveCode: pageData.weaveCode,
          inspectionState: pageData.inspectionState == -1 ? undefined : pageData.inspectionState,
          adjustmentState: pageData.adjustmentState == -1 ? undefined : pageData.adjustmentState
        },
      })
          .then(({data, code, message}: any) => {
            if (code === 200) {
              table.handleSuccess(data.list)
              gridOption.value.setRowData(data.list)
              total.value = data.total
            } else {
              Message.error({
                content: message,
                duration: 5000,
              })
            }
          })
          .catch(console.log)
          .finally(() => {
            pageData.pageLoading = false
          })
    }

    const {selectedRowKeys, onSelectionChange} = useRowSelection()
    const pagination = usePagination(doRefresh)
    const table = useTable()
    const rowKey = useRowKey('id')
    const tableColumns = useTableColumn([
      // {
      //     title: "序号",
      //     key: "id",
      //     dataIndex: "id",
      //     width: 150,
      // },
      {
        title: '公司',
        key: 'firm',
        dataIndex: 'firm',
        width: 150,
      },
      {
        title: '调机单号',
        key: 'adjustmentCode',
        dataIndex: 'adjustmentCode',
        width: 150,
      },
      {
        title: '机台号',
        key: 'machineCode',
        dataIndex: 'machineCode',
        width: 150,
      },
      {
        title: '楼层',
        key: 'areaName',
        dataIndex: 'areaName',
        width: 150,
      },
      {
        title: '生产单号',
        key: 'weaveCode',
        dataIndex: 'weaveCode',
        width: 150,
      },
      {
        title: '织布单号',
        key: 'planOrderCode',
        dataIndex: 'planOrderCode',
        width: 150,
      },
      {
        title: '坯布编号',
        key: 'greyCode',
        dataIndex: 'greyCode',
        width: 150,
      },
      {
        title: '坯布名称',
        key: 'grayName',
        dataIndex: 'grayName',
        width: 150,
      },
      {
        title: '调机开始日期',
        key: 'empStartTime',
        dataIndex: 'empStartTime',
        width: 150,
      },
      {
        title: '调机布重量',
        key: 'adjustmentClothWeight',
        dataIndex: 'adjustmentClothWeight',
        width: 150,
      },

      {
        title: '查布头次数',
        key: 'firstCount',
        dataIndex: 'firstCount',
        width: 150,
      },
      {
        title: '完结状态',
        key: 'adjustmentState',
        dataIndex: 'adjustmentState',
        slotName: 'adjustmentState',
        width: 150,
        fixed: 'right'
      },
      {
        title: '查布头结果',
        key: 'inspectionState',
        dataIndex: 'inspectionState',
        slotName: 'inspectionState',
        width: 200,
        fixed: 'right'
      },
      {
        title: '操作',
        key: "act",
        slotName: 'act',
        width: 150, fixed: 'right'
      }
    ])
    let tc: any[] = tableColumns.map((o) => {
      let obj = {
        headerName: o.title,
        field: o.key,
        pinned: o['fixed'],
        tooltipField: o.key,
      }
      //
      if (o.slotName === 'act') {
        obj['resizable'] = false
        obj['filter'] = false
        obj['sortable'] = false
        obj['lockPosition'] = 'right'
        obj['width'] = 122
        obj['cellRenderer'] = {
          template: `
            <a-space>
              <el-button style="color:#165dff;" link @click="a" v-if="f">详情</el-button>
              <el-button style="color:#165dff;" link @click="b" v-if="f">登记</el-button>
            </a-space>
          `,
          setup(props: any) {
            const a = () => {
              handleClick(props.params.data)
            }
            const b = () => {
              handleClick1(props.params.data)
            }
            props.params.data.inspectionState
            let f = permissionStore.hasPermisson('sjjlcx.xg')
            return {
              a,
              f,
              b,
            }
          },
        }
      }
      if (o.slotName === 'inspectionState') {
        obj['resizable'] = false
        obj['filter'] = false
        obj['sortable'] = false
        obj['width'] = 200
        obj['cellRenderer'] = {
          template: `
            <a-space>
              <el-tag class="ml-2" v-if="a == 1" type="success">{{ val }}</el-tag>
              <el-tag class="ml-2" v-if="a == 0" type="warning">{{ val }}</el-tag>
              <el-tag class="ml-2" v-if="a == 2" type="success">{{ val }}</el-tag>
            </a-space>
          `,
          setup(props: any) {
            let val = ref()
            val.value = props.params.data.inspectionState == 0 ? '未检验' : props.params.data.inspectionState == 1 ? '不OK' : 'OK'
            return {
              val,
              a: props.params.data.inspectionState,
            }
          },
        }
      }
      if (o.slotName === 'adjustmentState') {
        obj['resizable'] = false
        obj['filter'] = false
        obj['sortable'] = false
        obj['width'] = 110
        obj['cellRenderer'] = {
          template: `
            <a-space>
              <el-tag class="ml-2" v-if="a" type="success">{{ val }}</el-tag>
              <el-tag class="ml-2" v-else type="warning">{{ val }}</el-tag>
            </a-space>
          `,
          setup(props: any) {
            let val = ref()
            val.value = props.params.data.adjustmentState >= 3 ? '已完结' : '未完结'
            return {
              val,
              a: props.params.data.adjustmentState >= 3,
            }
          },
        }
      }

      return obj
    })

    let a = [
      {
        showRowGroup: 'hide_def',
        headerName: '',
        checkboxSelection: true,
        headerCheckboxSelection: true,
        pinned: 'left',
        width: 50,
        resizable: false,
        filter: false,
        sortable: false,
        minWidth: 50,
        maxWidth: 50,
        lockPosition: 'left',
      },
    ]
    tc = a.concat(tc)

    const pageData = reactive<{
      dateEnd: any
      dateStart: any
      showAdd: boolean
      sideTitle: string
      dropDownData: any
      // dropDownData1: any,
      nameList: []
      nameList2: []
      pageLoading: boolean
      typeList: []
      dropDownData1: any
      rHeight: any
      btnList: any[]
      isEdit: boolean
      TypeNameList: any[]
      file: string
      isShow: boolean
      isShow2: boolean
      planOrderCode: any
      adjustmentCode: any
      weaveCode: any
      inspectionState: any
      defectNameList: any[]
      adjustmentState: any
      remark: any
    }>({
      remark: '',
      dateEnd: '',
      dateStart: '',
      nameList: [],
      nameList2: [],
      showAdd: false,
      sideTitle: '新增程序号',
      dropDownData: '',
      pageLoading: false,
      typeList: [],
      dropDownData1: '',
      rHeight: 0,
      btnList: [],
      isEdit: false,
      TypeNameList: [],
      file: '',
      isShow: false,
      isShow2: false,
      planOrderCode: "",
      adjustmentCode: "",
      weaveCode: "",
      inspectionState: 0,
      defectNameList: [],
      adjustmentState: 2
    })

    interface gcType {
      id: any
      company: any
    }

    //调机类型下拉框得到焦点
    const focusSel = () => {
      selCxAll({adjustmentTypeName: ''})
    }

    //下拉数据
    const options = ref<any>(pageData.nameList)
    const loading = ref(false)
    const handleSearch = (value: any) => {
      if (value) {
        const ob = {adjustmentTypeName: value}
        loading.value = true
        selCxAll(ob)
        options.value = pageData.nameList
        loading.value = false
      } else {
        options.value = []
      }
    }

    //下拉框查询
    function selCxAll(val: any) {
      post({
        url: '/qms/AdjustmentType/getFieldValue',
        data: val,
      }).then(({data, code}: any) => {
        if (code === 200) {
          pageData.nameList = data
        } else {
          Message.error({
            content: '查询失败！',
            duration: 5000,
          })
        }
      })
    }

    onMounted(() => {
      doRefresh()
      // 切换tap到本页面执行的方法
      emitter.on('FirstInspectionRecordListDemo', () => {
        doRefresh()
      })
      pageData.rHeight = document.getElementsByClassName('arco-tabs-content')[0]?.clientHeight
      //弹出层的高
      if (pageData.rHeight !== undefined) {
        pageData.rHeight = pageData.rHeight - 100
      }
      window.addEventListener('resize', () => {
        pageData.rHeight = document.getElementsByClassName('arco-tabs-content')[0]?.clientHeight
        //弹出层的高
        if (pageData.rHeight !== undefined) {
          pageData.rHeight = pageData.rHeight - 100
        }
      })
    })

    let cxbl = {}
    //查询
    const selectHandler = () => {
      pagination.page = 1
      cxbl = pageData.dropDownData
      doRefresh()
    }
    const queryData = reactive({
      programType: '',
    })

    // 表格准备事件
    const gridOption = ref()
    const colState = ref()
    const gridReady = (params: any) => {
      gridOption.value = params.api
      colState.value = params.columnApi
    }

    const formRef = ref<FormInstance>()


    const handleChange = (_data: any) => {
      table.handleSuccess(_data)
    }
    const defaultColDef = {
      sortable: true,
      resizable: true,
      filter: true,
      // flex: 1
    }

    const localeText1: any = ref(localeText)
    const huiche = () => {
      doRefresh()
    }
    const pagingList1: any = ref(pagingList)

    //设置权限
    // ['查询', '新增', '删除', '导出', '导入']
    const permissionStore = usePermission()

    if (permissionStore.hasPermisson('sjjlcx.cx')) {
      pageData.btnList.push('查询')
      pageData.btnList.push('导出')
    }
    // if (permissionStore.hasPermisson('sjjlcx.dc')) {
    //   pageData.btnList.push('导出')
    // }
    // if (permissionStore.hasPermisson('sjjlcx.sc')) {
    //   pageData.btnList.push('删除')
    // }
    //详情
    const visible = ref(false);

    const handleClick = (record: BrandInfo) => {
      post({
        url: '/qms/FirstverifyRecord/getListByAdjustmentCode',
        data: {adjustmentCode: record['adjustmentCode']},
      }).then(({data, code, message}: any) => {
        if (code === 200) {
          for (let key in record) {
            dataForm[key] = record[key]
          }
          dataForm.list = data
          visible.value = true;
        } else {
          Message.error({
            content: message,
            duration: 5000,
          })
        }
      })

    };
    const handleOk = () => {
      visible.value = false;
    };
    const handleCancel = () => {
      visible.value = false;
    }
    //登记
    const visible1 = ref(false);

    const handleClick1 = (record: BrandInfo) => {
      for (let key in record) {
        dataForm[key] = record[key]
      }
      dataForm['defectNames'] = []
      dataForm['adjustmentClothWeight'] = 0
      // dataForm.defectNames=  dataForm.defectNames.split(',')
      findUserToken();

      getDefectName()

    };
    const handleCancel1 = () => {
      if (dataForm.adjustmentClothWeight == null || dataForm.adjustmentClothWeight == 0) {
        Message.warning({
          content: '请填写调机布重量！',
          duration: 5000,
        })
        return
      }
      var date = new Date();
      let Y = date.getFullYear() + '-';
      let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
      let D = date.getDate() + '';
      dataForm.firstverifyDate = Y + M + D
      dataForm['verifySureOk'] = 0
      dataForm['id'] = undefined
      dataForm.defectNames = dataForm.defectNames.join(',')
      // dataForm['adjustmentClothWeight'] = 0
      post({
        url: '/qms/FirstverifyRecord/insert',
        data: [dataForm],
      }).then(({data, code, message}: any) => {
        if (code === 200) {
          Message.success({
            content: '登记成功！',
            duration: 5000,
          })
          visible1.value = false;
          doRefresh()
        } else {
          Message.error({
            content: message,
            duration: 5000,
          })
        }
      })


    }

    function okClick() {
      if (dataForm.adjustmentClothWeight == null || dataForm.adjustmentClothWeight == 0) {
        Message.warning({
          content: '请填写调机布重量！',
          duration: 5000,
        })
        return
      }
      var date = new Date(dataForm.firstverifyDate);
      let Y = date.getFullYear() + '-';
      let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
      let D = date.getDate() + '';
      dataForm.firstverifyDate = Y + M + D
      dataForm['verifySureOk'] = 1
      dataForm['id'] = undefined
      dataForm.defectNames = dataForm.defectNames.join(',')
      post({
        url: '/qms/FirstverifyRecord/insert',
        data: [dataForm],
      }).then(({data, code, message}: any) => {
        if (code === 200) {
          Message.success({
            content: '登记成功！',
            duration: 5000,
          })
          visible1.value = false;
          doRefresh()
        } else {
          Message.error({
            content: message,
            duration: 5000,
          })
        }
      })

    }

    const tableColumnsCf = useTableColumn([

      {
        title: '查布头人员',
        key: 'firstverifyUser',
        dataIndex: 'firstverifyUser',
        width: 150,
      },
      {
        title: '调机布重量',
        key: 'adjustmentClothWeight',
        dataIndex: 'adjustmentClothWeight',
        width: 150,
      },


      {
        title: '查布头日期',
        key: 'firstverifyDate',
        dataIndex: 'firstverifyDate',
        width: 150,
      },
      {
        title: '疵点问题',
        key: 'defectNames',
        dataIndex: 'defectNames',
        width: 150,

      },
      {
        title: '查布头结果',
        key: 'verifySureOk',
        dataIndex: 'verifySureOk',
        width: 200,
        slotName: 'verifySureOk',
      },
      {
        title: '备注',
        key: 'remark',
        dataIndex: 'remark',
        width: 150,
      },
    ])

    //查询当前账号
    function findUserToken() {
      post({
        url: 'admin/acl/user/findUserToken',
        data: {}
      }).then(({data, code, message}: any) => {
        if (code === 200) {
          if (Object.keys(data.data['empMap']).length == 0) {
            Message.error({
              duration: 5000,
              content: '此账号未关联员工!'
            })
          } else {
            dataForm['firstverifyUser'] = data.data['empMap']['name']
            visible1.value = true;
          }
        } else {
          Message.error({
            content: message,
            duration: 5000,
          })
        }
      })
    }

    //查询疵点
    function getDefectName() {
      post({
        url: 'qms/defectType/select',
        data: {
          deleteState: 0
        }
      }).then(({data, code, message}: any) => {
        if (code === 200) {
          console.log(data);

          pageData.defectNameList = data
        } else {
          Message.error({
            content: message,
            duration: 5000,
          })
        }
      })
    }

    const {saveGridState: saveGridState01, updateGridState: updateGridState01} = saveOrUpdateGridState01('FirstInspectionRecordListDemo-1', gridOption, colState, tc)
    const onColumnMoved = () => {
      saveGridState01()
    }
    const onColumnResized = () => {
      saveGridState01()
    }
    const onColumnVisible = () => {
      saveGridState01()
    }
    const exports = () => {
      post({
        url: '/planSingle/adjustment/getExportExcel',
        data: {
          startDate: pageData.dateStart,
          endDate: pageData.dateEnd,
          adjustmentCode: pageData.adjustmentCode,
          planOrderCode: pageData.planOrderCode,
          weaveCode: pageData.weaveCode,
          inspectionState: pageData.inspectionState == -1 ? undefined : pageData.inspectionState,
          adjustmentState: pageData.adjustmentState == -1 ? undefined : pageData.adjustmentState
        },
      })
          .then(({data, code}: any) => {
            if (code === 200) {
              EXELTABLE(tc, data, '查布头记录列表')
            }
          })
    }
    return {
      saveOrUpdateGridState01,
      saveGridState01,
      updateGridState01,
      onColumnMoved,
      onColumnResized,
      onColumnVisible,
      colState,
      okClick,
      handleCancel1,
      handleClick1,
      visible1,
      tableColumnsCf,
      visible,
      handleClick,
      handleOk,
      handleCancel,
      pagingList1,
      huiche,
      localeText1,
      formRef,
      dataForm,
      selectedRowKeys,
      pagination,
      tableColumns,
      table,
      rowKey,
      pageData,
      queryData,
      selectHandler,
      options,
      loading,
      handleSearch,
      focusSel,
      headerShow,
      handleChange,
      PageSize,
      change1,
      defaultColDef,
      tc,
      gridOption,
      gridReady,
      total,
      page,
      size,
      exports
    }
  },
  components: {Toolbar, PageTabelLayout, },
}
</script>
<style scoped lang="less">
:deep(.ag-cell) {
  border-right: 1px solid #dde2eb;
}

:deep(.ag-header-cell) {
  border-right: 1px solid #dde2eb;
}

:deep(.ag-cell-value) {
  user-select: initial;
  -moz-user-select: text;
  -ms-user-select: text;
  -webkit-user-select: text;
}
</style>